var app = {}

var defaultOption = {
    select(aim){
        if(aim&&aim.className)aim.className+=" selected";
    },
    clear(aim){
        if(aim&&aim.className)aim.className = aim.className.replace(" selected","");
    }
}

app.Singler = function(option){
    var prev;
    var value;
    option = Object.assign({},defaultOption,option)
    this.select = function(e,v){
        var aim = e&&e.currentTarget||e
        value = v;
        option.clear(prev)
        option.select(aim)
        prev = aim
    }
    this.getSelected = function(){
        return prev
    }
    this.getValue = function(){
        return value
    }
}

module.exports = app